
def type_lists_setup(db):
    create_prime_type_sql = "create table prime_type (name text, ct int, mt int, stat int)"
    create_sub_type_sql = "create table sub_type (name text, prime text, ct int, mt int, stat int)"
    db.execute(create_prime_type_sql)
    db.execute(create_sub_type_sql)
    
    

class ModelTypeList():

    #default_prime = []
    def __init__(self):
        #this should be a dict of lists
        #keys are "prime keys"
        #list contents are sub types
        self.default_setup()
        self.load()
        
    def default_setup(self):
        self.data = {
            'work':['programming', 'meeting'],
            'study':['reading', ],
            'relax':['sleep', 'eat'],
            }

    def load(self):
        import DataManager
        l = DataManager.DataManager.db.querry('select name from prime_type')
        keys = self.data.keys()
        for i in l:
            if i not in self.keys:
                self.data[i] = []
        keys = self.data.keys()
        for i in keys:
            l = DataManager.DataManager.db.querry("select name from sub_type where prime == '%s'"%(i))
            for j in l:
                if i not in self.data[i]:
                    self.data[i].append(i)
        

    def merge(self, prime_list, sub_list):
        pass

    def get_data(self):
        return self.data
